import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)//vue的插件机制

const defaultState = {
  token: uni.getStorageSync('Token'),
  avatar: '',
  articleCategoryId: '',
}
const store = new Vuex.Store({
    state: defaultState,
    getters: {
      token: state => state.token,
      avatar: state => state.avatar,
      articleCategoryId: state => state.articleCategoryId,
    },
    mutations: {
      setToken(state, token) {
        state.token = token
      },
      setAvatar(state, avatar) {
        state.avatar = avatar
      },
      setArticleCategoryId(state, articleCategoryId) {
        state.articleCategoryId = articleCategoryId
      },
    }
})
export default store